package com.cat.recruit.bean.dto;

import com.cat.recruit.entity.AppointmentSlot;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Time;
import java.sql.Date;
import java.time.LocalDate;

@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "预约时间段")
@Data
public class AppointmentSlotDTO {
    /**
     * 主键
     */
    @Schema(description = "主键")
    private Integer id;

    /**
     * 考核项目名称
     */
    @Schema(description = "考核项目名称")
    private String accessType;

    /**
     * 预约日期
     */
    @Schema(description = "预约日期")
    private LocalDate appointmentDate;

    /**
     * 开始时间
     */
    @Schema(description = "开始时间")
    private Time startTime;

    /**
     * 结束时间
     */
    @Schema(description = "结束时间")
    private Time endTime;

    /**
     * 预约人数上限
     */
    @Schema(description = "预约人数上限")
    private Integer capacity;

    /**
     * 已预约人数
     */
    @Schema(description = "已预约人数")
    private Integer appointedCount = 0;

    @Schema(description = "选择方向")
    private String direction;

    public AppointmentSlotDTO(AppointmentSlot appointmentSlot) {
            this.id = appointmentSlot.getId();
            this.accessType = appointmentSlot.getAccessType();
            this.appointmentDate = appointmentSlot.getAppointmentDate().toLocalDate();
            this.startTime = appointmentSlot.getStartTime();
            this.endTime = appointmentSlot.getEndTime();
            this.capacity = appointmentSlot.getCapacity();
            this.appointedCount = appointmentSlot.getAppointedCount();
            this.direction = appointmentSlot.getDirection();
    }
}
